package com.dc.kylin.rabbitmq.controller;

public class Test {

    private static boolean stop = false;
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            int count = 0;
            while(!stop){
                count++;
                //System.out.println();   //增加这行，会跳出while循环，原因是System.out.println()中有synchronized
            }
            System.out.println("worker thread count: " + count );
        });
        thread.start();
        try {
            Thread.sleep(100);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        stop = true;
        System.out.println("Main thread stopped to true");
    }
}
